home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / sched / sched.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  4.1 KB  |  146 lines

  1. /*
  2.  * sched.h --
  3.  *
  4.  *    Declarations of procedures exported by the sched module.
  5.  *
  6.  * Copyright 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * rcsid $Header: /cdrom/src/kernel/Cvsroot/kernel/sched/sched.h,v 9.6 91/12/12 12:29:29 mgbaker Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _SCHED
  14. #define _SCHED
  15.  
  16. #ifdef KERNEL
  17. #include <timer.h>
  18. #include <proc.h>
  19. #include <mach.h>
  20. #include <sync.h>
  21. #else
  22. #include <kernel/timer.h>
  23. #include <kernel/proc.h>
  24. #include <kernel/mach.h>
  25. #include <kernel/sync.h>
  26. #endif
  27.  
  28. /*
  29.  * Flags for the schedFlags in the proc table.
  30.  *
  31.  *    SCHED_CONTEXT_SWITCH_PENDING    A context switch came in while context
  32.  *                    switching was disabled.
  33.  *    SCHED_CLEAR_USAGE        Clear usage information for this
  34.  *                    process when scheduling it.  Intended
  35.  *                    to be used by kernel worker processes.
  36.  *    SCHED_STACK_IN_USE        The stack of this process is being
  37.  *                    used by a processor.  The processor 
  38.  *                    field of the Proc_ControlBlock 
  39.  *                    specifies what processor is using it. 
  40.  */
  41.  
  42. #define SCHED_CONTEXT_SWITCH_PENDING    0x1
  43. #define    SCHED_CLEAR_USAGE        0x2    
  44. #define    SCHED_STACK_IN_USE        0x4
  45.  
  46. typedef struct Sched_Instrument {
  47.     /*
  48.      * Per processor numbers.
  49.      */
  50.     struct perProcessor {
  51.     /* 
  52.      * Total number of context switches. 
  53.      */
  54.     int    numContextSwitches;        
  55.     
  56.     /* 
  57.      * Only those due to end of quantum. 
  58.      */
  59.     int    numInvoluntarySwitches;    
  60.     
  61.     /* 
  62.      * Number of switches that cause a different process to run.
  63.      */
  64.     int numFullCS;            
  65.  
  66.     /* 
  67.      * Amount of time w/o running process.  
  68.      */
  69.     Timer_Ticks noProcessRunning;    
  70.     
  71.     /* 
  72.      * Converted value of noProcessRunning that is only computed when
  73.      * this struct is copied out to user space.
  74.      */
  75.     Time idleTime;            
  76.     
  77.     /* 
  78.      * Free running counter that is ++'d inside the idle loop.  It is used
  79.      * to measure CPU utilization.
  80.      */
  81.     unsigned int idleTicksLow;        
  82.     /* 
  83.      * Make the counter into 64 bits 
  84.      */
  85.     unsigned int idleTicksOverflow;
  86.         unsigned int idleTicksPerSecond;    /* Calibrated value */
  87.  
  88. #if     (MACH_MAX_NUM_PROCESSORS != 1) 
  89.     /*
  90.      * Pad the structure to insure that two structure occur in the
  91.      * same cache block.  This is to prevent pinging of cache blocks
  92.      * between processor in a multiprocessor such as SPUR while 
  93.      * incrementing the IdleLoop counter.
  94.      */
  95.      Mach_CacheBlockSizeType    pad;
  96. #endif
  97.     } processor[MACH_MAX_NUM_PROCESSORS];
  98.  
  99.     int numReadyProcesses;        /* Number of ready processes at time
  100.                      * of call to copy information */
  101.  
  102.     Time noUserInput;            /* Time since last level-6 interrupt */
  103. } Sched_Instrument;
  104.  
  105. typedef struct {
  106.     Proc_ControlBlock        *procPtr;
  107. #if     (MACH_MAX_NUM_PROCESSORS != 1) 
  108.    Mach_CacheBlockSizeType    pad;
  109. #endif
  110. } Sched_OnDeck;
  111.  
  112. extern Sched_OnDeck    sched_OnDeck[MACH_MAX_NUM_PROCESSORS];
  113.  
  114. /*
  115.  * External declarations:
  116.  */
  117.     
  118. extern Sync_Semaphore sched_Mutex;    /* Mutual exclusion in scheduler */
  119.  
  120. extern Sync_Semaphore *sched_MutexPtr;
  121. extern Sched_Instrument sched_Instrument;   /* Counters for instrumentation. */
  122. extern int sched_Quantum;        /* Timer interrupts per quantum. */
  123. extern Sched_OnDeck    sched_OnDeck[MACH_MAX_NUM_PROCESSORS];
  124.  
  125. extern void Sched_MakeReady _ARGS_((register Proc_ControlBlock *procPtr));
  126. extern void Sched_StartUserProc _ARGS_((Address pc));
  127. extern void Sched_StartKernProc _ARGS_((void (*func)()));
  128. extern void Sched_ContextSwitch _ARGS_((Proc_State state));
  129. extern void Sched_ContextSwitchInt _ARGS_((register Proc_State state));
  130. extern void Sched_ForgetUsage _ARGS_((Timer_Ticks time, ClientData clientData));
  131. extern void Sched_GatherProcessInfo _ARGS_((unsigned int interval));
  132. extern void Sched_Init _ARGS_((void));
  133. extern void Sched_TimeTicks _ARGS_((void));
  134. extern void Sched_LockAndSwitch _ARGS_((void));
  135. extern ReturnStatus Sched_StartProcessor _ARGS_((int pnum));
  136. extern ReturnStatus Sched_IdleProcessor _ARGS_((int pnum));
  137. extern void Sched_InsertInQueue _ARGS_((Proc_ControlBlock *procPtr, 
  138.                     Proc_ControlBlock **runPtrPtr));
  139. extern void Sched_PrintStat _ARGS_((void));
  140. extern void Sched_SetClearUsageFlag _ARGS_((void));
  141. extern void Sched_DumpReadyQueue _ARGS_((ClientData dummy));
  142. extern void Sched_StartSchedStats _ARGS_((void));
  143. extern void Sched_StopSchedStats _ARGS_((void));
  144.  
  145. #endif /* _SCHED */
  146.